POV-Ray : Newsgroups : povray.unofficial.patches : PovRay faster : Re: PovRay faster Server Time
1 Sep 2024 22:14:47 EDT (-0400)
  Re: PovRay faster  
From: Thorsten Froehlich
Date: 4 Feb 2001 21:04:09
Message: <3a7e0a19@news.povray.org>
In article <3a7d7dbf@news.povray.org> , "Daniel Jungmann" <DSJ### [at] gmxnet> 
wrote:

> Which compiler does these things?

Every compiler should do basic optimisations.  Sometimes they don't tell you
want exactly they do.  What you are seeking can be called any of the terms
below, but other names or methods are possible [1].  The list of
optimizations below is not complete and not precise, but should give you an
idea what to look for in your compiler documentation.

> 1) loops

- loop-invariant code motion (takes out code that doesn't change in a loop)
- loop unrolling (on expense of code size, reduces branches for loops)

> 2) float divisions (replace mutiple divisions with one division and
> multiplications)

- Replacing division by constants with multiplaction

See important issues regarding applying other optimisations to
floating-point numbers in [1, section 12.3.2]!

> 3) if then / ? :

Taken care of by the intermediate code representation in any compiler.

> 4) integer multiplications and divisions (replace them with shift or
> additions)

- Strength reduction (this is exactly what you are suggesting)
- Algebraic simplification and reassociation (associativity, commutativity,
distributivity)
- Value numbering (eliminating one of two equivalent calculations), note
that some compilers can do this on a global level!

> 5) multiple integer calculations

- constant folding (calculates constants before they are compiled)

In addition, compilers can do things that are hard to do for a human in
assembly language, such as register coloring (reusing registers to hold
different variables that are both in scope but not used at the same time),
instruction scheduling accoring to the processor manufacture's instruction
execution time tables (this is one of the things why you can pick the

instruction scheduling (avoid stalls in processor pipeline).

Now, all these listed optimisations and many more are probably in every
compiler you have, but to be specific, all of them are supported by the
Intel compiler according to [1].  And I am sure most of them (if working
seems to be another matter, as I am told) are in Visual C++, too.


  Thorsten


____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org



[1] Muchnick, Steven S., Advanced Compiler Design and Implementation
    ISBN 1-55860-320-4

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.